def getrandstr(len)
  ('A'..'Z').to_a.sort_by{rand}[0..len-1].to_s
end
def diff(ori, obj)
  (0..ori.size-1).to_a.select{|x| ori[x] != obj[x]}
end
def change(ori, compare)
  ret = ori.clone
  indexes = diff(ori, compare)
  rand = getrandstr(indexes.size).split ''
  indexes.each { |x| ret[x] = rand.shift }
  ret
end
def monkey(ori)
  cnt = 0
  while(1)
    prc = cnt == 0 ? getrandstr(ori.size) : change(ori, prc)
    puts "#{cnt}:#{prc}"
    cnt = cnt + 1
    if(prc == ori)
      break
    end
  end
end

monkey('HEYJIN')
